<template>
  <div>
    <!-- 时间线 -->
    <el-timeline>
      <p style="font-size: 25px; font-weight: 800">疫情快讯</p>
      <el-timeline-item
        :timestamp="timeformat(item.createTime)"
        placement="top"
        v-for="item in newData"
        :key="item.id"
      >
        <el-card>
          <a :href="item.newHref" target="_blank"
            ><h4>{{ item.title }}</h4></a
          >
        </el-card>
      </el-timeline-item>
    </el-timeline>
  </div>
</template>

<script>
export default {
  name: 'news-timeline',
  data() {
    return {
      title: '',
      newData: []
    }
  },
  created() {
    // 请求分页查询的数据
    this.load()
  },

  methods: {
    timeformat(data) {
      return this.$moment(data).format('yyyy-MM-DD HH:ss')
    },
    // 请求分页查询的数据
    load() {
      this.$http.get('/covidnews').then((res) => {
        console.log(res)
        this.newData = res.data
      })
    }
  }
}
</script>

<style>
</style>